@extends('layouts.app')
@section('title', '话题详情')
@section('styles')
  <link href="/static/layuiadmin/style/template.css" rel="stylesheet">
@endsection

@section('content')

<div class="layui-fluid layadmin-homepage-fluid">
  <div class="layui-row layui-col-space8 layadmin-caller">
    <div class="layui-col-md2">
      <div class="layadmin-homepage-panel layadmin-homepage-shadow">
        <div class="layui-card text-center">
          <div class="layui-card-body">
            <div class="layadmin-homepage-pad-ver">
              <img class="layadmin-homepage-pad-img" src="{{$topic->user->avatar}}" width="96" height="96">
            </div>
            <h4 class="layadmin-homepage-font">{{$topic->user->name}}</h4>
            <p class="layadmin-homepage-min-font">管理员</p>
            <button class="layui-btn layui-btn-fluid">关注</button>
          </div>
        </div>
        <p class="layadmin-homepage-about">
          个人简介
        </p>
        <div class="layadmin-homepage-pad-hor">
          <mdall>{{$topic->user->introduction}}</mdall>
        </div>
        <p class="layadmin-homepage-about">
          注册于<br>{{ $topic->user->created_at->diffForHumans() }}
        </p>
      </div>
    </div>
    <div class="layui-col-md10">
      <div class="layui-row layui-col-space20 layadmin-homepage-list-imgtxt">
          <div class="layui-col-md9 layui-col-space20">
            <div class="grid-demo">
              <div class="panel-body layadmin-homepage-shadow">
                <div class="media-body">
                  <div class="pad-btm">
                    <p class="fontColor"><span>{{$topic->title}}</span></p>
                    <p class="min-font">
                      <span class="layui-breadcrumb" lay-separator="-">
                        <a href="javascript:;">{{$topic->updated_at->diffForHumans()}}</a>
                        <a href="javascript:;">{{$topic->reply_count}} 回复</a>
                      </span>
                    </p>
                  </div>
                  <p>{{$topic->body}}</p>
                  <div class="media">
                    <div class="media-right">
                      <ul class="list-inline">
                        @can('update', $topic)
                        <li>
                          <a href="{{route('topics.edit', $topic->id)}}" class="layui-btn  btn-sm">编辑</a>
                        </li>
                        @endcan
                        @can('update', $topic)
                        <li>
                          <form action="{{ route('topics.destroy', $topic->id) }}" method="post"
                                style="display: inline-block;"
                                onsubmit="return confirm('您确定要删除吗？');">
                            {{ csrf_field() }}
                            {{ method_field('DELETE') }}
                            <button type="submit" class="layui-btn btn-sm">
                              删除
                            </button>
                          </form>
                        </li>
                        @endcan
                      </ul>
                    </div>
                  </div>
                  <!-- 回复框 -->
                  @includeWhen(Auth::check(), 'topics._reply_box', ['topic' => $topic])
                  <!-- 用户评论 -->
                  <div class="media-list">
                    @if($topic->replies->count() > 0)
                      @foreach($topic->replies as $reply)
                        @include('topics._reply_list_item', ['reply'=>$reply])
                      @endforeach
                    @endif
                   <a href="javascript:;" class="layui-btn">更多</a>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

    </div>
  </div>
</div>

@endsection
